/*
 * Templates Bezier Curve class
 * BezierCurve<JPvec2>
 * BezierCurve<JPVec3>
 */
#ifndef _BEZIERCURVE_H_
#define _BEZIERCURVE_H_

#include <vector>

#include "JPVec2.h"
#include "JPVec3.h"

template<class V>
class BezierCurve
{
public:

	BezierCurve(){};
	BezierCurve(unsigned int degree);

	/*
	 * Adds a node to the curve
	 */
	void addNode(const V &node);

	/*
	 * Returns the degree of this curve
	 */
	unsigned int degree() const { return m_nodes.size(); }

	/*
	 * Returns a point on the curve at the specified parameter between (0 - 1.0f)
	 */
	V pointOnCurve(float t) const;

private:

	typedef std::vector<V> NodeList;

	void pointOnCurveInternal(NodeList &nodeList, float t, V &result) const;

	NodeList m_nodes;
};

#define BezierCurve2D BezierCurve<JPVec2>
#define BezierCurve3D BezierCurve<JPVec3>

#endif // _BEZIERCURVE_H_